package o;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
import androidx.recyclerview.widget.RecyclerView.ItemAnimator;
import androidx.recyclerview.widget.RecyclerView.s;
import o.hg.c;
import o.hg.e;

public class ms {
    @VisibleForTesting
    final dw<s> ˊ = new dw();
    @VisibleForTesting
    final ds<s, b> ˏ = new ds();

    static class b {
        static e<b> ˊ = new c(20);
        @Nullable
        ItemAnimator.c ˋ;
        @Nullable
        ItemAnimator.c ˎ;
        int ॱ;

        private b() {
        }

        static b ˏ() {
            b bVar = (b) ˊ.ˎ();
            return bVar == null ? new b() : bVar;
        }

        static void ॱ(b bVar) {
            bVar.ॱ = 0;
            bVar.ˎ = null;
            bVar.ˋ = null;
            ˊ.ˋ(bVar);
        }

        static void ˊ() {
            do {
            } while (ˊ.ˎ() != null);
        }
    }

    public interface d {
        void ˊ(s sVar, @Nullable ItemAnimator.c cVar, ItemAnimator.c cVar2);

        void ˋ(s sVar);

        void ˋ(s sVar, @NonNull ItemAnimator.c cVar, @Nullable ItemAnimator.c cVar2);

        void ˎ(s sVar, @NonNull ItemAnimator.c cVar, @NonNull ItemAnimator.c cVar2);
    }

    public void ॱ() {
        this.ˏ.clear();
        this.ˊ.ˊ();
    }

    public void ˋ(s sVar, ItemAnimator.c cVar) {
        b bVar = (b) this.ˏ.get(sVar);
        if (bVar == null) {
            bVar = b.ˏ();
            this.ˏ.put(sVar, bVar);
        }
        bVar.ˎ = cVar;
        bVar.ॱ |= 4;
    }

    public boolean ˊ(s sVar) {
        b bVar = (b) this.ˏ.get(sVar);
        return (bVar == null || (bVar.ॱ & 1) == 0) ? false : true;
    }

    @Nullable
    public ItemAnimator.c ॱ(s sVar) {
        return ॱ(sVar, 4);
    }

    @Nullable
    public ItemAnimator.c ˋ(s sVar) {
        return ॱ(sVar, 8);
    }

    private ItemAnimator.c ॱ(s sVar, int i) {
        ItemAnimator.c cVar = null;
        int ˎ = this.ˏ.ˎ((Object) sVar);
        if (ˎ >= 0) {
            b bVar = (b) this.ˏ.ˋ(ˎ);
            if (!(bVar == null || (bVar.ॱ & i) == 0)) {
                bVar.ॱ &= i ^ -1;
                if (i == 4) {
                    cVar = bVar.ˎ;
                } else if (i == 8) {
                    cVar = bVar.ˋ;
                } else {
                    throw new IllegalArgumentException("Must provide flag PRE or POST");
                }
                if ((bVar.ॱ & 12) == 0) {
                    this.ˏ.ˏ(ˎ);
                    b.ॱ(bVar);
                }
            }
        }
        return cVar;
    }

    public void ˋ(long j, s sVar) {
        this.ˊ.ˎ(j, sVar);
    }

    public void ˊ(s sVar, ItemAnimator.c cVar) {
        b bVar = (b) this.ˏ.get(sVar);
        if (bVar == null) {
            bVar = b.ˏ();
            this.ˏ.put(sVar, bVar);
        }
        bVar.ॱ |= 2;
        bVar.ˎ = cVar;
    }

    public boolean ˎ(s sVar) {
        b bVar = (b) this.ˏ.get(sVar);
        return (bVar == null || (bVar.ॱ & 4) == 0) ? false : true;
    }

    public s ˏ(long j) {
        return (s) this.ˊ.ˋ(j);
    }

    public void ˏ(s sVar, ItemAnimator.c cVar) {
        b bVar = (b) this.ˏ.get(sVar);
        if (bVar == null) {
            bVar = b.ˏ();
            this.ˏ.put(sVar, bVar);
        }
        bVar.ˋ = cVar;
        bVar.ॱ |= 8;
    }

    public void ˏ(s sVar) {
        b bVar = (b) this.ˏ.get(sVar);
        if (bVar == null) {
            bVar = b.ˏ();
            this.ˏ.put(sVar, bVar);
        }
        r0.ॱ |= 1;
    }

    public void ᐝ(s sVar) {
        b bVar = (b) this.ˏ.get(sVar);
        if (bVar != null) {
            bVar.ॱ &= -2;
        }
    }

    public void ˋ(d dVar) {
        for (int size = this.ˏ.size() - 1; size >= 0; size--) {
            s sVar = (s) this.ˏ.ॱ(size);
            b bVar = (b) this.ˏ.ˏ(size);
            if ((bVar.ॱ & 3) == 3) {
                dVar.ˋ(sVar);
            } else if ((bVar.ॱ & 1) != 0) {
                if (bVar.ˎ == null) {
                    dVar.ˋ(sVar);
                } else {
                    dVar.ˋ(sVar, bVar.ˎ, bVar.ˋ);
                }
            } else if ((bVar.ॱ & 14) == 14) {
                dVar.ˊ(sVar, bVar.ˎ, bVar.ˋ);
            } else if ((bVar.ॱ & 12) == 12) {
                dVar.ˎ(sVar, bVar.ˎ, bVar.ˋ);
            } else if ((bVar.ॱ & 4) != 0) {
                dVar.ˋ(sVar, bVar.ˎ, null);
            } else if ((bVar.ॱ & 8) != 0) {
                dVar.ˊ(sVar, bVar.ˎ, bVar.ˋ);
            } else if ((bVar.ॱ & 2) != 0) {
            }
            b.ॱ(bVar);
        }
    }

    public void ʽ(s sVar) {
        for (int ˎ = this.ˊ.ˎ() - 1; ˎ >= 0; ˎ--) {
            if (sVar == this.ˊ.ˏ(ˎ)) {
                this.ˊ.ॱ(ˎ);
                break;
            }
        }
        b bVar = (b) this.ˏ.remove(sVar);
        if (bVar != null) {
            b.ॱ(bVar);
        }
    }

    public void ˏ() {
        b.ˊ();
    }

    public void ʻ(s sVar) {
        ᐝ(sVar);
    }
}
